﻿using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;


[CustomEditor(typeof(PanerlManager))]
public class EditorPanel : Editor
{
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        PanerlManager panerlManager = (PanerlManager) target;

        GUILayout.Label("执行前需要先创建文件");
        string str = panerlManager.Path;
        
        if (GUILayout.Button("Create"))
        {
            panerlManager.Create();
            Debug.Log("创建成功");
        }
        
        if (GUILayout.Button("Save"))
        {
            panerlManager.OutPutFile();
            Debug.Log("保存成功" + panerlManager.Path);
            AssetDatabase.Refresh();//刷新资源
        }

        

        GUILayout.TextArea(str);
        
        if (GUILayout.Button("Read"))
        {
            panerlManager.ReadInFile();
            Debug.Log("读取成功 ："+ panerlManager.Path);
        }


        if (GUILayout.Button("Clear"))
        {
            panerlManager.ClearAll();
            Debug.Log("清除成功!");
        }
        
        
    }
}
